package it.irondev.appturismo.service.impl;

import it.irondev.appturismo.dao.CityMapper;
import it.irondev.appturismo.dao.example.CityExample;
import it.irondev.appturismo.dao.example.CityExample.Criteria;
import it.irondev.appturismo.entity.City;
import it.irondev.appturismo.filter.BaseFilter;
import it.irondev.appturismo.service.ICityService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CityServiceImpl implements ICityService {

	@Autowired
	CityMapper cityDao;
	
	
	public List<City> getAllCity() {
		return cityDao.selectByExample(null);
	}


	public List<City> getCityByFilter(BaseFilter filter) {
		CityExample example = null;
 		if(filter!=null) {
			example = new CityExample();
			Criteria criteria = example.createCriteria();
			if(filter.getId()!=null)
				criteria.andIdcityEqualTo(filter.getId());
//			if(filter.getIdlanguage()!=null)
//				criteria.andLanguageEqualTo(filter.getIdlanguage());
			example.or(criteria);
		}
		return cityDao.selectByExample(example);
	}

}
